<?php
/**
 * CompleXml Framework
 *
 * @category   CompleXml
 * @package    CompleXml_Config
 * @copyright  Copyright (c) 2008 Andrey Kucherenko
 * @license    New BSD License
 * @version    $Id: Config.php 8 2008-11-13 14:50:42Z kucherenko.andrey $
 */

final class CompleXml_Config
{
    private static $_config;
    private static $_index = 0;
    static public function set ($name, $value)
    {
        if (isset(self::$_config[ $name ]) && is_array(self::$_config[ $name ]) && is_array($value)) {
            foreach (array_keys(self::$_config[ $name ]) as $key) {
                if (isset($value[ $key ])) {
                    self::$_config[ $name ][ $key ] = $value[ $key ];
                    unset($value[ $key ]);
                }
            }
            self::$_config[ $name ] = array_merge(self::$_config[ $name ], $value);
        } else {
            self::$_config[ $name ] = $value;
        }
    }
    static public function setArray ($array)
    {
        foreach ($array as $key=>$value) {
        	self::set($key, $value);
        }
                
    }
    static public function get ($name)
    {
        if (! isset(self::$_config[ $name ])) {
            require_once 'CompleXml/Config/Exception.php';
            throw new CompleXml_Config_Exception('Variable not found in config');
        }
        return self::$_config[ $name ];
    }
    static public function read ($filename, CompleXml_Config_Reader_Abstract $config_reader)
    {
        $config_reader->read_file($filename);
    }
    private function __construct ()
    {
    }
    private function __clone ()
    {
    }
} 